<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <meta name="description" content="">
  <meta name="author" content="">
  <title>新闻管理</title>
  <!-- Bootstrap core CSS -->
  <link href="/css/bootstrap.min.css" rel="stylesheet">
  <!-- Custom styles for this template -->
  <link href="/css/dashboard.css" rel="stylesheet">
</head>

<body>
<!--顶部菜单 -->
<div th:replace="~{topleft::topnav}"></div>
<div class="container-fluid">
  <div class="row">
    <!--左菜单 -->
    <div th:replace="~{topleft::#sidebarMenu(lurl='leftuser')}"></div>
    <main role="main" class="col-md-9 ml-sm-auto col-lg-10 pt-3 px-4">
      <h2><a th:href="@{/news/add}" class="btn btn-success btn-sm mb-2">添加新闻</a></h2>
      <div class="table-responsive">
        <form action="#" th:action="@{/news}" method="get">
          <label>标题:<input type="text" name="title" th:value="${title}"/>&nbsp;
            <button type="submit" class="btn btn-success btn-sm" value="搜索">搜索</button></label>
        </form>
        <table class="table table-sm table-hover table-bordered">
          <thead>
          <tr>
            <th>ID</th>
            <th>标题</th>
            <th>作者</th>
            <th>发布日期</th>
            <th>操作</th>
          </tr>
          </thead>
          <tbody>
          <tr th:each="news : ${newsList}">
            <td th:text="${news.id}"></td>
            <td th:text="${news.title}"></td>
            <td th:text="${news.author}"></td>
            <td th:text="${news.publishDate}"></td>
            <td>
              <a th:href="@{/news/{id}(id=${news.id})}" class="btn btn-info btn-sm">查看</a>
              <a th:href="@{/news/edit/{id}(id=${news.id})}" class="btn btn-info btn-sm">编辑</a>
              <a th:href="@{/news/delete/{id}(id=${news.id})}" class="btn btn-danger btn-sm">删除</a>
            </td>
          </tr>
          </tbody>
        </table>
        <nav aria-label="Page navigation example">
          <ul class="pagination">
            <li class="page-item">
              <a class="page-link" th:href="@{/news(pno=${page.navigateFirstPage},title=${title})}" aria-label="Previous">
                <span aria-hidden="true">首页</span>
              </a>
            </li>
            <li class="page-item" th:if="${page.hasNextPage}">
              <a class="page-link" th:href="@{/news(pno=${page.nextPage},title=${title})}">下页</a>
            </li>
            <li class="page-item" th:if="${page.hasPreviousPage}">
              <a class="page-link" th:href="@{/news(pno=${page.prePage},title=${title})}">上页</a>
            </li>
            <li class="page-item">
              <a class="page-link" th:href="@{/news(pno=${page.navigateLastPage},title=${title})}" aria-label="Next">
                <span aria-hidden="true">末页</span>
              </a>
            </li>
          </ul>
        </nav>
      </div>
    </main>
  </div>
</div>

<!-- Bootstrap core JavaScript
  ================================================== -->
<script type="text/javascript" src="/js/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/js/popper.min.js"></script>
<script type="text/javascript" src="/js/bootstrap.min.js"></script>

<!-- Icons -->
<script type="text/javascript" src="/js/feather.min.js"></script>
<script>
  feather.replace()
</script>

</body>

</html>
